package org.jeecg.modules.nurse_user_bill.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.modules.nurse_user_bill.service.INurseUserBillInvoiceService;
import org.jeecg.modules.nurse_user_bill.vo.OpenInvoiceRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "数电发票管理")
@RestController
@RequestMapping("/nurse_user_bill/nurseUserBillInvoice")
@Slf4j
public class NurseUserBillInvoiceController {

    @Autowired
    private INurseUserBillInvoiceService iNurseUserBillInvoiceService;

    /**
     * 开具电子发票
     *
     * @param invoiceResponseRequest
     * @return
     */
    @AutoLog(value = "开具电子发票")
    @ApiOperation(value = "开具电子发票", notes = "开具电子发票")
    @PostMapping(value = "/openElectronicInvoice")
    public Result<Object> openElectronicInvoice(@RequestBody OpenInvoiceRequest invoiceResponseRequest) {
        try {
            iNurseUserBillInvoiceService.openElectronicInvoice(invoiceResponseRequest);
        } catch (Exception e) {
            return Result.error("开具电子发票失败: " + e.getMessage(), e.getMessage());
        }
        return Result.OK("开具电子发票成功");
    }

}
